package com.pm.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.pm.common.annotation.Log;
import com.pm.common.core.controller.BaseController;
import com.pm.common.core.domain.AjaxResult;
import com.pm.common.enums.BusinessType;
import com.pm.business.domain.CurrentProjectAward;
import com.pm.business.service.ICurrentProjectAwardService;
import com.pm.common.utils.poi.ExcelUtil;
import com.pm.common.core.page.TableDataInfo;

/**
 * 项目获奖Controller
 * 
 * @author zxl
 * @date 2022-05-08
 */
@RestController
@RequestMapping("/business/current_project_award")
public class CurrentProjectAwardController extends BaseController
{
    @Autowired
    private ICurrentProjectAwardService currentProjectAwardService;

    /**
     * 查询项目获奖列表
     */
    @PreAuthorize("@ss.hasPermi('business:current_project_award:list')")
    @GetMapping("/list")
    public TableDataInfo list(CurrentProjectAward currentProjectAward)
    {
        startPage();
        List<CurrentProjectAward> list = currentProjectAwardService.selectCurrentProjectAwardList(currentProjectAward);
        return getDataTable(list);
    }

    /**
     * 导出项目获奖列表
     */
    @PreAuthorize("@ss.hasPermi('business:current_project_award:export')")
    @Log(title = "项目获奖", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CurrentProjectAward currentProjectAward)
    {
        List<CurrentProjectAward> list = currentProjectAwardService.selectCurrentProjectAwardList(currentProjectAward);
        ExcelUtil<CurrentProjectAward> util = new ExcelUtil<CurrentProjectAward>(CurrentProjectAward.class);
        util.exportExcel(response, list, "项目获奖数据");
    }

    /**
     * 获取项目获奖详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:current_project_award:query')")
    @GetMapping(value = "/{awardId}")
    public AjaxResult getInfo(@PathVariable("awardId") Long awardId)
    {
        return AjaxResult.success(currentProjectAwardService.selectCurrentProjectAwardByAwardId(awardId));
    }

    /**
     * 新增项目获奖
     */
    @PreAuthorize("@ss.hasPermi('business:current_project_award:add')")
    @Log(title = "项目获奖", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CurrentProjectAward currentProjectAward)
    {
        return toAjax(currentProjectAwardService.insertCurrentProjectAward(currentProjectAward));
    }

    /**
     * 修改项目获奖
     */
    @PreAuthorize("@ss.hasPermi('business:current_project_award:edit')")
    @Log(title = "项目获奖", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CurrentProjectAward currentProjectAward)
    {
        return toAjax(currentProjectAwardService.updateCurrentProjectAward(currentProjectAward));
    }

    /**
     * 删除项目获奖
     */
    @PreAuthorize("@ss.hasPermi('business:current_project_award:remove')")
    @Log(title = "项目获奖", businessType = BusinessType.DELETE)
	@DeleteMapping("/{awardIds}")
    public AjaxResult remove(@PathVariable Long[] awardIds)
    {
        return toAjax(currentProjectAwardService.deleteCurrentProjectAwardByAwardIds(awardIds));
    }
}
